package com.twu.biblioteca;

public class Book {

    String title;
    String author;
    boolean available;

    public Book(String title, String author){
        this.title = title;
        this.author = author;
        available = true;
    }

    public boolean getAvailability(){
        return available;
    }

    public void setAvailability(boolean availability){
        available = availability;
    }

    public String toString(){
        return  title + " by "+author;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Book book = (Book) o;

        if (author != null ? !author.equals(book.author) : book.author != null) return false;
        if (title != null ? !title.equals(book.title) : book.title != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = title != null ? title.hashCode() : 0;
        result = 31 * result + (author != null ? author.hashCode() : 0);
        return result;
    }
}
